package com.ruoyi.user.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.InnerAuth;
import com.ruoyi.user.domain.CheCoupon;
import com.ruoyi.user.service.ICheCouponService;
import com.ruoyi.user.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/coupon")
@CrossOrigin
public class CheCouponController {
    @Autowired
    private ICheCouponService cheCouponService;

    @GetMapping("/list")
    public AjaxResult getList(CheCoupon cheCoupon){
        List<CheCoupon> list = cheCouponService.selectCheCouponList(cheCoupon);
        return AjaxResult.success(list);
    }
    @GetMapping("/{id}")
    public AjaxResult getById(@PathVariable("id") Long id){
        CheCoupon cheCoupon = cheCouponService.selectCheCouponById(id);
        return AjaxResult.success(cheCoupon);
    }


    @PostMapping("/insert")
    public AjaxResult insertCheCoupon(@RequestBody CheCoupon cheCoupon){
       cheCouponService.insertCheCoupon(cheCoupon);
        return AjaxResult.success();
    }
}
